﻿@using Seal.Model
@using Seal.Helpers
@using SealWebServer.Controllers
@using SealWebServer.Models.Configuration
@{
    WebMainModel model = Model as WebMainModel;
    Repository repository = model.Repository;
    var authenticationConfig = ViewData["AuthenticationConfig"] as Authentication;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>@repository.Configuration.WebProductName </title>
    <meta charset="utf-8" />

    <link href="~/Images/faviconWebServer.ico" rel="shortcut icon" type="image/x-icon" />

    <link rel="stylesheet" href="~/Content/datatables.min.css" />
    <link rel="stylesheet" href="~/Content/font-awesome.min.css" />
    <link rel='stylesheet' href='~/Content/jstree-style.min.css' />
    <link rel="stylesheet" href="~/Content/bootstrap-select.min.css" />
    <link rel='stylesheet' href='~/Content/bootstrap-datetimepicker.min.css' />
    <link rel="stylesheet" href="~/Content/sealweb.css" />
    <link rel="stylesheet" href="~/Content/nv.d3.min.css" />
    @foreach (var fileName in Helper.GetStringList(repository.Configuration.WebCssFiles))
    {
        <link rel="stylesheet" href="~/Content/@fileName" />
    }
    @foreach (var fileName in Helper.GetStringList(repository.Configuration.CssFiles))
    {
        <link rel="stylesheet" href="~/Content/@fileName" />
    }
    <link rel="stylesheet" href="~/Content/seal.css" />
</head>
<body>
    <!--disable autofill for Chrome-->
    <input type="text" style="display:none">
    <input type="password" style="display:none">
    <input type="hidden" name="id_load" id="id_load" value="" />

    @await Html.PartialAsync("~/Views/Home/Menu.cshtml")

    <!--Folders view -->
    <div id="main-container" class="container-fluid folderview" style="padding-top:62px;display:none;">
        <div class="row">
            <div id="folder-view" class="col-sm-4" style="padding-right:0px">
                <div class="jstree jstree-default" id="folder-tree" role="tree" style="overflow:auto;border-radius:10px;"></div>
            </div>

            <div id="file-view" class="col-sm-8" style="padding-right:0px">
                <!-- Report Menus -->
                <div id="file-menu" class="lighticon-menu hidden-xs" style="margin-bottom:10px">
                    <div id="report-edit-lightbutton" class="lightbutton report-edit"><span class="lightbutton-icon fa fa-file-o"></span><br /><span class="lightbutton-text">@repository.TranslateWeb("New")</span></div>
                    <div id="report-cut-lightbutton" class="lightbutton"><span class="lightbutton-icon fa fa-cut"></span><br /><span class="lightbutton-text">@repository.TranslateWeb("Cut")</span></div>
                    <div id="report-copy-lightbutton" class="lightbutton"><span class="lightbutton-icon fa fa-copy"></span><br /><span class="lightbutton-text">@repository.TranslateWeb("Copy")</span></div>
                    <div id="report-paste-lightbutton" class="lightbutton"><span class="lightbutton-icon fa fa-paste"></span><br /><span class="lightbutton-text">@repository.TranslateWeb("Paste")</span></div>
                    <div id="report-delete-lightbutton" class="lightbutton"><span class="lightbutton-icon fa fa-remove"></span><br /><span class="lightbutton-text">@repository.TranslateWeb("Delete")</span></div>
                    <div id="report-rename-lightbutton" class="lightbutton"><span class="lightbutton-icon fa fa-file-text"></span><br /><span class="lightbutton-text">@repository.TranslateWeb("Rename")</span></div>
                    <div id="report-upload-lightbutton" class="lightbutton"><span class="lightbutton-icon fa fa-upload"></span><br /><span class="lightbutton-text">@repository.TranslateWeb("Upload")</span></div>
                </div>
                <div id="file-table-view" style="overflow:auto;">
                    <table id="file-table" class="table table-striped table-hover">
                        <thead id="file-table-head"></thead>
                        <tbody id="file-table-body"></tbody>
                    </table>
                </div>
                    <form id="upload-file-form" class="hidden">
                        <input id="upload-file" type="file" name="file" />
                    </form>
            </div>

        </div>
    </div>

    <!--Report view-->
    <div id="report-body" class="container-fluid reportview" style="display:none;">
    </div>

    @await Html.PartialAsync("~/Views/Home/Dialogs.cshtml")

    <!-- Views and Output -->
    <div id="output-panel" class="panel panel-default" style="display:none;">
        <div class="panel-heading" style="height:20px;padding: 0px 10px;"><button type='button' id="output-panel-close" class='close'>&times;</button></div>
        <div id="output-panel-content">
            <table class="table table-striped">
                <thead>
                    <tr><th>@repository.TranslateWeb("Name")</th><th></th><th>@repository.TranslateWeb("Type")</th></tr>
                </thead>
                <tbody id="output-table-body"></tbody>
            </table>
        </div>
    </div>

    @if (model.HasEditor)
    {
        @await Html.PartialAsync("~/Views/Home/MainEditor.cshtml")
    }

    <div id="footer-div" style="position:fixed; bottom:10px; text-align:center; width:100%">
        <div>
            <p>Copyright &copy; @DateTime.Now.Year Seal Report. All Rights Reserved (version <span id="footer-version">@Repository.ProductVersion</span>)</p>
        </div>
    </div>

    <script src="~/Scripts/datatables.min.js"></script>
    <script src="~/Scripts/jstree.min.js"></script>
    <script src="~/Scripts/bootstrap-select.min.js"></script>
    <script type="text/javascript" src="~/Scripts/moment.min.js"></script>
    @if (repository.CultureInfo.TwoLetterISOLanguageName != "en")
    {
        <script src="~/Scripts/@("i18n/moment." + repository.CultureInfo.TwoLetterISOLanguageName + ".js")"></script>
        <script src="~/Scripts/@("i18n/selectpicker." + repository.CultureInfo.TwoLetterISOLanguageName + ".min.js")"></script>
    }
    <script src="~/Scripts/bootstrap-datetimepicker.min.js"></script>
    <script src="~/Scripts/datetime-moment.js"></script>

    <!-- common libraries -->
    <script src="~/Scripts/helpers.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script src="~/Scripts/gauge.min.js"></script>
    <script src="~/Scripts/d3.min.js"></script>
    @if (repository.CultureInfo.TwoLetterISOLanguageName != "en")
    {
        <script src="~/Scripts/d3-time.v1.min.js"></script>
        <script src="~/Scripts/d3-time-format.v2.min.js"></script>
        <script src="~/Scripts/@("d3/" + repository.CultureInfo.TwoLetterISOLanguageName + ".js")"></script>
    }

    @foreach (var fileName in Helper.GetStringList(repository.Configuration.WebScriptFiles))
    {
        <script type='text/javascript' src='~/Scripts/@fileName'></script>
    }
    @foreach (var fileName in Helper.GetStringList(repository.Configuration.ScriptFiles))
    {
        <script type='text/javascript' src='~/Scripts/@fileName'></script>
    }

    <script type="text/javascript">
        //server
        var WebApplicationName = '@HomeController.GetWebUrl(Context.Request, Context.Response)';

        //formats
        var decimalSeparator = '@Html.Raw(repository.CultureInfo.NumberFormat.NumberDecimalSeparator)';
        var thousandSeparator = '@Html.Raw(Helper.ToJS(repository.CultureInfo.NumberFormat.NumberGroupSeparator))';
        var dirSeparator = '@(System.IO.Path.DirectorySeparatorChar == '\\' ? "\\\\" : System.IO.Path.DirectorySeparatorChar.ToString())';
        //for datepicker
        var languageName = '@repository.CultureInfo.TwoLetterISOLanguageName';
        var shortDateFormat = '@repository.MomentJSShortDateFormat';
        var shortDateTimeFormat = '@repository.MomentJSShortDateTimeFormat';
        var isUSdate = shortDateFormat.match(/^m/i);

        var folderRightSchedule = @((int) FolderRight.Schedule);
        var folderRightEdit = @((int) FolderRight.Edit);

        //translations
        var tra = [];
        @foreach (var translation in repository.JSTranslations)
        {
            <text>tra["@Helper.ToJS(translation.Key)"] = "@Helper.ToJS(translation.Value)";
            </text>
        }
        var opers = [];
        @if (model.HasEditor)
        {
            foreach (var oper in Enum.GetValues(typeof(Operator)))
            {
                <text>opers[@((int)oper)] = "@Helper.ToJS(repository.TranslateWebJS(Helper.GetEnumDescription(typeof(Operator), oper)))";</text>
            }
        }

        //datatables defaults
        $.fn.dataTable.moment(shortDateFormat);
        $.fn.dataTable.moment(shortDateTimeFormat);
        $.extend( true, $.fn.dataTable.defaults, {
                responsive: {
                    details: {
                        renderer: function (api, rowIdx, columns) {
                            return dtRenderer(api, rowIdx, columns);
                        }
                    }
                },
                columnDefs: [
                    { orderable: false, targets: ["firstcell"]},
                        {
                            targets: "_all",
                            createdCell: function (td, cellData, rowData, row, col) {
                                dtCreatedCell(td, cellData, rowData, row, col);
                            }
                        }
            ],
            language: {
                decimal: decimalSeparator,
                thousands: thousandSeparator,
                processing: "@Html.Raw(Helper.ToJS(repository.TranslateReport("Processing...")))",
                lengthMenu: "@Html.Raw(Helper.ToJS(repository.TranslateReport("Show _MENU_ rows")))",
                zeroRecords: "@Html.Raw(Helper.ToJS(repository.TranslateReport("No rows")))",
                emptyTable: "@Html.Raw(Helper.ToJS(repository.TranslateReport("No records")))",
                info: "@Html.Raw(Helper.ToJS(repository.TranslateReport("Showing _START_ to _END_ of _TOTAL_")))",
                infoEmpty: "@Html.Raw(Helper.ToJS(repository.TranslateReport("Showing 0 to 0 of 0")))",
                infoFiltered: "@Html.Raw(Helper.ToJS(repository.TranslateReport("(filtered from _MAX_)")))",
                infoPostFix: "",
                search: "@Html.Raw(Helper.ToJS(repository.TranslateReport("Filter:")))",
                paginate: {
                    first: "|&lt;",
                    previous: "&lt;&lt;",
                    next: ">>",
                    last: ">|"
                }
            },
            pagingType: "full_numbers",
            autoWidth: false,
            stateSave: false,
        });

        //keyword
        var displayNameKeyword = '@Repository.SealReportDisplayNameKeyword2';

        var hasEditor = @Helper.ToJS(model.HasEditor);
    </script>

    @if (!model.HasMinifiedScripts())
    {
        <script src="~/Scripts/swi-utils.js"></script>
        <script src="~/Scripts/swi-gateway.js"></script>
        <script src="~/Scripts/swi-main.js"></script>

        if (model.HasEditor)
        {
            <script src="~/Scripts/swi-gateway-editor.js"></script>
            <script src="~/Scripts/swi-button-group.js"></script>
            <script src="~/Scripts/swi-editor.js"></script>
            <script src="~/Scripts/swi-properties.js"></script>
        }
    }
    else
    {
        <script src="~/Scripts/swi.js"></script>
    }

    @Html.Raw(RazorHelper.CompileExecute(repository.Configuration.WebMainAdditionalScript, model))
</body>
</html>
